package com.hh.config;

import com.hh.component.AdminInterceptor;
import com.hh.component.CookieInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration  /*以spring的bean形式创建代理对象   加载一个springbean*/   /*运行过程中被执行*/
public class MyMvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //addInterceptor  添加拦截的类（拦截器类）
        //addPathPatterns   添加要拦截的请求
        //excludePathPatterns  不拦截的需求
//        registry.addInterceptor(new CookieInterceptor()).addPathPatterns("/index").excludePathPatterns();
        registry.addInterceptor(new CookieInterceptor()).addPathPatterns("/**").excludePathPatterns();
//        registry.addInterceptor(new AdminInterceptor()).addPathPatterns("/*/admin/*", "/*");
        registry.addInterceptor(new AdminInterceptor()).addPathPatterns("/*/admin/*");
    }
}
